define(['aPermissionCard','knockout','util'], function (APermissionCard,ko,Util) {
    function ViewModel(params) {
        Util.extend(this, params);

        var scope = this;

        var selectRow = undefined;

        scope.card = {
            title: '菜单树',
            titleButtons: [],
            //cardBody: ko.observable()
            cardBody:{
                name: 'cmp:TreeGrid',
                params: {
                    operations: [],
                    keyDataField:'id',
                    parentDataField:'fatherId',
                    displayFields:['name','key','href','typeName','icon','order'],
                    store: {model:'mMenu',id:'menuStore'},
                    onRowSelect:function (data) {
                        selectRow = data;
                        ko.root.storeCache[scope.card.cardBody.params.store.id].model.default = {fatherId :data.id};
                    },
                    onNoneRowSelect:function () {
                        selectRow = undefined;
                        ko.root.storeCache[scope.card.cardBody.params.store.id].model.default = {};
                    }
                }
            }
        };

        this.callParent(params);
    }

    ViewModel.extend(APermissionCard);

    return ViewModel;
});
